//
//  CommentaryViewController.m
//  LOLProject
//
//  Created by lanou3g on 15/5/26.
//  Copyright (c) 2015年 lanou3g.com蓝欧科技. All rights reserved.
//

#import "CommentaryViewController.h"

@interface CommentaryViewController ()

@end

@implementation CommentaryViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
//    设置背景颜色
    self.view.backgroundColor=[UIColor whiteColor];
//    创建gameCommentaryTableView并作为默认视图
    [self createGameCommentaryTableView];
//    创建heroVideoTableView,暂不使用
    [self createHeroVideoCollectionView];
//    创建dMXYTableView,暂不使用
    [self createDMXYTableView];
//    默认显示游戏解说
    self.commentarySegmentedControl.selectedSegmentIndex=0;
    [self select:self.commentarySegmentedControl];
//    设置UISearchBar的代理
    self.commentarySearchBar.delegate=self;
//    设置UISearchBar的barStyle
    self.commentarySearchBar.barStyle=UIBarStyleBlackTranslucent;
//    设置UISearchBar的键盘风格
    self.commentarySearchBar.keyboardType=UIKeyboardTypeDefault;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

#pragma mark---设置UISegmentedControl添加的方法
- (void) select:(id)sender{
//    获取单例
    CommentaryDataHandle * commentaryDataHandle=[CommentaryDataHandle sharedInstance];
//    获取segmentedControl
    UISegmentedControl * segmentedControl= (UISegmentedControl *) sender;
    switch (segmentedControl.selectedSegmentIndex) {
        case 0:
//            切换到游戏解说视图
            [self goToGameCommentaryTableView];
//            给最新视频数组分配空间,并赋初值
            self.gameCommentaryDataArray=[NSMutableArray array];
        {
//            定义gameCommentaryBlock
            __weak CommentaryViewController * commentaryVC=self;
            commentaryDataHandle.gameCommentaryBlock= ^ void (NSMutableArray * array){
                commentaryVC.gameCommentaryDataArray=array;
                [commentaryVC.gameCommentaryTableView reloadData];
            };
        }
//            从网上请求数据(还需要进一步完善)
            [commentaryDataHandle requestCommentaryData:0];
            break ;
        case 1:
//            切换到英雄视频视图
            [self goToHeroVideoCollectionView];
//            给英雄视频数组分配空间,并赋初值
            self.heroVideoDataArray=[NSMutableArray array];
        {
//            定义heroVideoBlock
            __weak CommentaryViewController * commentaryVC=self;
            commentaryDataHandle.heroVideoBlock= ^ void (NSMutableArray * array){
                commentaryVC.heroVideoDataArray=array;
                [commentaryVC.heroVideoCollectionView reloadData];
            };
        }
//            从网上请求数据
            [commentaryDataHandle requestCommentaryData:1];
            break ;
        case 2:
//            切换到德玛西亚视图
            [self goToDMXYTableView];
//            给德玛西亚数组分配空间,并赋初值
            self.dMXYDataArray=[NSMutableArray array];
        {
//            定义dMXYBlock
            __weak CommentaryViewController * commentaryVC=self;
            commentaryDataHandle.dMXYBlock= ^ void (NSMutableArray * array){
                commentaryVC.dMXYDataArray=array;
                [commentaryVC.dMXYTableView reloadData];
            };
        }
//            从网上请求数据(还需要进一步完善)
            [commentaryDataHandle requestCommentaryData:2];
            break ;
    }
    return ;
}

#pragma  mark---切换到游戏解说视图
- (void) goToGameCommentaryTableView{
    if(self.heroVideoCollectionView.superview!=nil){
        [UIView transitionFromView:self.heroVideoCollectionView toView:self.gameCommentaryTableView duration:1.0 options:UIViewAnimationOptionTransitionFlipFromLeft completion:nil];
    }else if(self.dMXYTableView!=nil){
        [UIView transitionFromView:self.dMXYTableView toView:self.gameCommentaryTableView duration:1.0 options:UIViewAnimationOptionTransitionFlipFromLeft completion:nil];
    }else{
        return ;
    }
    return ;
}

#pragma mark---切换到英雄视频视图
- (void) goToHeroVideoCollectionView{
    if(self.gameCommentaryTableView.superview!=nil){
        [UIView transitionFromView:self.gameCommentaryTableView toView:self.heroVideoCollectionView duration:1.0 options:UIViewAnimationOptionTransitionFlipFromRight completion:nil];
    }else if(self.dMXYTableView!=nil){
        [UIView transitionFromView:self.dMXYTableView toView:self.heroVideoCollectionView duration:1.0 options:UIViewAnimationOptionTransitionFlipFromLeft completion:nil];
    }else{
        return ;
    }
    return ;
}

#pragma mark---切换到德玛西亚视图
- (void) goToDMXYTableView{
    if(self.gameCommentaryTableView.superview!=nil){
        [UIView transitionFromView:self.gameCommentaryTableView toView:self.dMXYTableView duration:1.0 options:UIViewAnimationOptionTransitionFlipFromRight completion:nil];
    }else if(self.heroVideoCollectionView!=nil){
        [UIView transitionFromView:self.heroVideoCollectionView toView:self.dMXYTableView duration:1.0 options:UIViewAnimationOptionTransitionFlipFromRight completion:nil];
    }else{
        return ;
    }
    return ;
}

#pragma mark---创建gameCommentaryTableView并作为默认视图
- (void) createGameCommentaryTableView{
//    创建gameCommentaryTableView
    self.gameCommentaryTableView=[[UITableView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([[UIScreen mainScreen] bounds]), CGRectGetHeight(self.containerView.frame)+70) style:UITableViewStylePlain];
//    将gameCommentaryTableView最为默认视图
    [self.containerView addSubview:self.gameCommentaryTableView];
//    设置代理
    self.gameCommentaryTableView.delegate=self;
    self.gameCommentaryTableView.dataSource=self;
//    设置gameCommentaryTableView的背景颜色
    self.gameCommentaryTableView.backgroundColor=[UIColor redColor];
//    设置gameCommentaryTableView的分割线样式
    self.gameCommentaryTableView.separatorStyle=UITableViewCellSeparatorStyleSingleLine;
//    设置gameCommentaryTableView的分割线的颜色
    self.gameCommentaryTableView.separatorColor=[UIColor cyanColor];
//    注册需要的使用的cell
    [self.gameCommentaryTableView registerNib:[UINib nibWithNibName:@"GameCommentaryTableViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:kGameCommentaryTableViewCell];
    return ;
}

#pragma mark---创建heroVideoTableView,暂不使用
- (void) createHeroVideoCollectionView{
//    创建heroVideoCollectionView
//    创建heroVideoCollectionView的样式
    UICollectionViewFlowLayout * flowLayout=[[UICollectionViewFlowLayout alloc] init];
    self.heroVideoCollectionView=[[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([[UIScreen mainScreen] bounds]), CGRectGetHeight(self.containerView.frame)+70) collectionViewLayout:flowLayout];
//    设置heroVideoCollectionView的背景颜色
    self.heroVideoCollectionView.backgroundColor=[UIColor greenColor];
//    设置heroVideoCollectionView的滑动方向
    flowLayout.scrollDirection=UICollectionViewScrollDirectionVertical;
//    设置itemSize
    flowLayout.itemSize=CGSizeMake(90, 120);
//    设置行间间距
    flowLayout.minimumLineSpacing=20;
//    设置列间距
    flowLayout.minimumInteritemSpacing=15;
//    设置heroVideoCollectionView的内边距
    flowLayout.sectionInset=UIEdgeInsetsMake(15, 15, 15, 15);
//    设置代理
    self.heroVideoCollectionView.delegate=self;
    self.heroVideoCollectionView.dataSource=self;
//    注册需要的使用的cell
    [self.heroVideoCollectionView registerNib:[UINib nibWithNibName:@"HeroVideoCollectionViewCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:kHeroVideoCollectionViewCell];
    return ;
}

#pragma mark---创建dMXYTableView,暂不使用
- (void) createDMXYTableView{
//    创建dMXYTableView
    self.dMXYTableView=[[UITableView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([[UIScreen mainScreen] bounds]), CGRectGetHeight(self.containerView.frame)+70) style:UITableViewStylePlain];
//    设置代理
    self.dMXYTableView.delegate=self;
    self.dMXYTableView.dataSource=self;
//    设置dMXYTableView的背景颜色
    self.dMXYTableView.backgroundColor=[UIColor yellowColor];
//    设置dMXYTableView的分割线样式
    self.dMXYTableView.separatorStyle=UITableViewCellSeparatorStyleSingleLine;
//    设置dMXYTableView的分割线的颜色
    self.dMXYTableView.separatorColor=[UIColor cyanColor];
//    注册需要的使用的cell
    [self.dMXYTableView registerNib:[UINib nibWithNibName:@"VideoGameTableViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:kDMXYTableViewCell];
    return ;
}

#pragma mark---德玛西亚详情的地址数组的懒加载
- (NSMutableArray *) dMXYDetailUrlArray{
    if (_dMXYDetailUrlArray==nil) {
        self.dMXYDetailUrlArray=[NSMutableArray array];
        [self.dMXYDetailUrlArray addObject:kLUOSHIDAI2];
        [self.dMXYDetailUrlArray addObject:kLUOSHIDAI1];
        [self.dMXYDetailUrlArray addObject:kDMXY4];
        [self.dMXYDetailUrlArray addObject:kDMXY3];
        [self.dMXYDetailUrlArray addObject:kDMXY2];
        [self.dMXYDetailUrlArray addObject:kDMXY1];
    }
    return _dMXYDetailUrlArray;
}

#pragma mark---实现UITableViewDelegate,UITableViewDataSource协议中的方法
#pragma mark---设置某区的行数
- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (self.commentarySegmentedControl.selectedSegmentIndex==0) {
        return [self.gameCommentaryDataArray count];
    }else if (self.commentarySegmentedControl.selectedSegmentIndex==1){
        return [self.heroVideoDataArray count];
    }else if (self.commentarySegmentedControl.selectedSegmentIndex==2){
        return [self.dMXYDataArray count];
    }else{
        return [self.searchDataArray count];
    }
}

#pragma mark---设置某行的内容
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (self.commentarySegmentedControl.selectedSegmentIndex==0) {
//        回收cell
        GameCommentaryTableViewCell * cell=[tableView dequeueReusableCellWithIdentifier:kGameCommentaryTableViewCell forIndexPath:indexPath];
//        回收不成功,就创建一个cell
        if (!cell) {
            cell=[[GameCommentaryTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kGameCommentaryTableViewCell];
        }
//        找到对应的对象
        Commentary * commentary=[self.gameCommentaryDataArray objectAtIndex:indexPath.row];
//        传值
        cell.commentary=commentary;
//        将内容显示在cell上
        [cell showCommentaryOnGameCommentaryTableViewCell];
        return cell;
    }else if (self.commentarySegmentedControl.selectedSegmentIndex==1){
        return nil;
    }else if(self.commentarySegmentedControl.selectedSegmentIndex==2){
//        回收cell
        VideoGameTableViewCell * cell=[tableView dequeueReusableCellWithIdentifier:kDMXYTableViewCell forIndexPath:indexPath];
//        回收不成功,就创建一个cell
        if (!cell) {
            cell=[[VideoGameTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kDMXYTableViewCell];
        }
//        找到对应的VideoGameList对象
        DMXY * dmxy=[self.dMXYDataArray objectAtIndex:indexPath.row];
//            传值
        cell.dmxy=dmxy;
//        将信息显示在cell上
        [cell showDMXYOnVideoGameTableViewCell];
        return cell;
    }else{
//        回收cell
        SearchTableViewCell * cell=[tableView dequeueReusableCellWithIdentifier:kSearchTableViewCell forIndexPath:indexPath];
//        回收不成功,及创建一个cell
        if (!cell) {
            cell=[[SearchTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kSearchTableViewCell];
        }
//        找到对应的对象searchTent
        SearchContent * searchContent=[self.searchDataArray objectAtIndex:indexPath.row];
//        将信息显示在cell上
        cell.textLabel.text=searchContent.title;
        return cell;
    }
}

#pragma mark---设置有多少分区
- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

#pragma mark---设置某行的高度
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (self.searchBarTableView.tag==105) {
        return 30;
    }else if (self.commentarySegmentedControl.selectedSegmentIndex==0){
        return 40;
    }else {
        return 120;
    }
}

#pragma mark---点击cell时触发的事件
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (self.commentarySegmentedControl.selectedSegmentIndex==0) {
//        创建游戏视频详情界面视图控制器
        GameCommentaryDetailTableViewController * gameCommentaryDetailTVC=[[GameCommentaryDetailTableViewController alloc] initWithNibName:@"GameCommentaryDetailTableViewController" bundle:[NSBundle mainBundle]];
//        将游戏详情界面详情视图控制器作为gameCommentaryDetailNC根视图控制器
        UINavigationController * gameCommentaryDetailNC=[[UINavigationController alloc] initWithRootViewController:gameCommentaryDetailTVC];
//        获取对应的commentary对象
        Commentary * commentary=[self.gameCommentaryDataArray objectAtIndex:indexPath.row];
//        设置游戏详情界面的标题
        gameCommentaryDetailTVC.navigationItem.title=commentary.flmc;
//        传值
        gameCommentaryDetailTVC.commentary=commentary;
//        模态推出游戏详情界面
        [self presentViewController:gameCommentaryDetailNC animated:YES completion:nil];
    }else if (self.commentarySegmentedControl.selectedSegmentIndex==1){
        ;
    }else if (self.commentarySegmentedControl.selectedSegmentIndex==2){
//        创建德玛西亚详情界面视图控制器
        DMXYDetailTableViewController * dmxyDetailTVC=[[DMXYDetailTableViewController alloc] initWithNibName:@"DMXYDetailTableViewController" bundle:[NSBundle mainBundle]];
//        将德玛西亚详情界面视图控制器作为dmxyDetailNC的根视图控制器
        UINavigationController * dmxyDetailNC=[[UINavigationController alloc] initWithRootViewController:dmxyDetailTVC];
//        获取对应的dmxy对象
        DMXY * dmxy=[self.dMXYDataArray objectAtIndex:indexPath.row];
//        设置德玛西亚详情界面的标题
        dmxyDetailTVC.navigationItem.title=dmxy.name;
//        传值
        dmxyDetailTVC.dmxyDetailUrl=[self.dMXYDetailUrlArray objectAtIndex:indexPath.row];
//        模态推出德玛西亚详情界面
        [self presentViewController:dmxyDetailNC animated:YES completion:nil];
    }else{
//        创建搜索视频详情视图控制器
        SearchVideoDetailTableViewController * searchVideoDetailTVC=[[SearchVideoDetailTableViewController alloc] initWithNibName:@"SearchVideoDetailTableViewController" bundle:[NSBundle mainBundle]];
//        将搜索视频详情视图控制器作为searchVideoDetailNC的根视图控制器
        UINavigationController * searchVideoDetailNC=[[UINavigationController alloc] initWithRootViewController:searchVideoDetailTVC];
//        找到对应的对象
        SearchContent * searchContent=[self.searchDataArray objectAtIndex:indexPath.row];
//        传值
        searchVideoDetailTVC.searchContent=searchContent;
//        设置搜索视频详情页面的标题
        searchVideoDetailTVC.navigationItem.title=searchContent.title;
//        模态推出搜索视频详情页面
        [self presentViewController:searchVideoDetailNC animated:YES completion:nil];
        return ;
    }
    return ;
}

#pragma mark---实现UICollectionViewDelegate,UICollectionViewDataSource协议中的方法
#pragma mark---设置某个区的Item的个数
- (NSInteger) collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return [self.heroVideoDataArray count];
}

#pragma mark---设置有多少个区
- (NSInteger) numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    return 1;
}

#pragma mark---设置某个Item的内容
- (UICollectionViewCell *) collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
//    回收cell
    HeroVideoCollectionViewCell * cell=[collectionView dequeueReusableCellWithReuseIdentifier:kHeroVideoCollectionViewCell forIndexPath:indexPath];

//    回去对应的对象
    Hero * hero=[self.heroVideoDataArray objectAtIndex:indexPath.item];
//    传值
    cell.hero=hero;
    [cell showHeroOnHeroVideoCollectionViewCell];
    return cell;
}

#pragma mark---点击Item时触发的方法
- (void) collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
//    创建英雄视频详情界面视图控制器
    HeroVideoDetailTableViewController * heroVideoDetailTVC=[[HeroVideoDetailTableViewController alloc] initWithNibName:@"HeroVideoDetailTableViewController" bundle:[NSBundle mainBundle]];
//    将英雄视频详情界面视图控制器作为heroVideoDetailNC根视图控制器
    UINavigationController * heroVideoDetailNC=[[UINavigationController alloc] initWithRootViewController:heroVideoDetailTVC];
//    获取对应的对象
    Hero * hero=[self.heroVideoDataArray objectAtIndex:indexPath.item];
//    设置英雄详情界面的标题
    heroVideoDetailTVC.navigationItem.title=hero.title;
//    传值
    heroVideoDetailTVC.hero=hero;
//    模态推出英雄详情界面
    [self presentViewController:heroVideoDetailNC animated:YES completion:nil];
    return ;
}

#pragma mark---实现UISearchBarDelegate协议中的方法
#pragma mark---将要点击searchBar时触发的方法
- (BOOL) searchBarShouldBeginEditing:(UISearchBar *)searchBar{
    self.commentarySearchBar.showsCancelButton=YES;
    self.searchBarTableView=[[UITableView alloc] initWithFrame:CGRectMake(0, 64, CGRectGetWidth([[UIScreen mainScreen] bounds]), CGRectGetHeight([[UIScreen mainScreen] bounds])-64)];
    self.searchBarTableView.backgroundColor=[UIColor whiteColor];
    self.searchBarTableView.tag=105;
    if (self.commentarySegmentedControl.selectedSegmentIndex==0) {
        [self.gameCommentaryTableView removeFromSuperview];
    }else if (self.commentarySegmentedControl.selectedSegmentIndex==1){
        [self.heroVideoCollectionView removeFromSuperview];
    }else if (self.commentarySegmentedControl.selectedSegmentIndex==2){
        [self.dMXYTableView removeFromSuperview];
    }else{
        ;
    }
    self.segmentIndex=self.commentarySegmentedControl.selectedSegmentIndex;
    self.commentarySegmentedControl.selectedSegmentIndex=-1;
    [self.view addSubview:self.searchBarTableView];
//    设置代理
    self.searchBarTableView.delegate=self;
    self.searchBarTableView.dataSource=self;
//    注册所需要的cell
    [self.searchBarTableView registerNib:[UINib nibWithNibName:@"SearchTableViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:kSearchTableViewCell];
//    添加取消
    self.buttonCancel=[UIButton buttonWithType:UIButtonTypeRoundedRect];
    self.buttonCancel.frame = CGRectMake(CGRectGetMaxX(self.commentarySearchBar.frame)-65,CGRectGetMinY(self.commentarySearchBar.frame), 65, CGRectGetHeight(self.commentarySearchBar.frame)+2);
    [self.buttonCancel addTarget:self action:@selector(cancelToCommentary) forControlEvents:UIControlEventTouchUpInside];
    [self.buttonCancel setBackgroundColor:[UIColor cyanColor]];
    self.buttonCancel.layer.cornerRadius=5;
    [self.buttonCancel setTitle:@"Cancel" forState:UIControlStateNormal];
    [self.view insertSubview:self.buttonCancel aboveSubview:self.commentarySearchBar];
    return  YES;
}

#pragma mark---实现给取消button添加的方法
- (void) cancelToCommentary{
    [self.commentarySearchBar isFirstResponder];
    self.commentarySearchBar.showsCancelButton=NO;
    [self.buttonCancel removeFromSuperview];
    [self.searchBarTableView removeFromSuperview];
    self.searchBarTableView.tag=0;
    self.commentarySegmentedControl.selectedSegmentIndex=self.segmentIndex;
    if (self.commentarySegmentedControl.selectedSegmentIndex==0) {
        [self.containerView addSubview:self.gameCommentaryTableView];
    }else if (self.commentarySegmentedControl.selectedSegmentIndex==1){
        [self.containerView addSubview:self.heroVideoCollectionView];
    }else if (self.commentarySegmentedControl.selectedSegmentIndex==2){
        [self.containerView addSubview:self.dMXYTableView];
    }else{
        ;
    }
    self.commentarySearchBar.text=@"";
    [self.commentarySearchBar resignFirstResponder];
    return ;
}

#pragma mark---编辑时开始搜索
- (void) searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText{
//    [self.searchDataArray removeAllObjects];
//    [self searchVideoBySearchText:searchText];
    return ;
}

#pragma mark---根据searchBar的内容搜索视频
- (void) searchVideoBySearchText:(NSString *) searchText{
//    异步连接下的GET请求
//    1.创建网址对象
    NSString * string=[[NSString stringWithFormat:kSearchVideoData_List_URL,searchText] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSURL * url=[NSURL URLWithString:string];
//    2.创建网络请求对象
    NSURLRequest * request=[NSURLRequest requestWithURL:url];
//    3.创建连接对象,并发送请求
    __weak CommentaryViewController * commentaryVC=self;
    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
//        代码保护
        if (data==nil) {
            return ;
        }
//        4.解析数据
        NSDictionary * sourceDic=[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
//        处理数据(封装model对象)
        for (NSDictionary * dic in [sourceDic objectForKey:@"r"]) {
            SearchContent * searchContent=[[SearchContent alloc] init];
            [searchContent setValuesForKeysWithDictionary:dic];
            [commentaryVC.searchDataArray addObject:searchContent];
        }
//        刷新数据
        [commentaryVC.searchBarTableView reloadData];
    }];
    return ;
}

#pragma mark---懒加载搜索数组searchDataArray
- (NSMutableArray *) searchDataArray{
    if (_searchDataArray==nil) {
        self.searchDataArray=[NSMutableArray array];
    }
    return _searchDataArray;
}

#pragma mark---回收键盘
- (void) searchBarSearchButtonClicked:(UISearchBar *)searchBar{
    [self.searchDataArray removeAllObjects];
    [self searchVideoBySearchText:self.commentarySearchBar.text];
    self.commentarySearchBar.text=@"";
    [searchBar resignFirstResponder];
    return ;
}

@end
